package com.zkingsoft.actions;

import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.model.Matain;
import com.zkingsoft.plugin.util.HttpUtils;
import com.zkingsoft.plugin.util.PropertiesUtils;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * @管理系统Controller
 */
@Controller
@RequestMapping(value = "/manage")
public class ManageController extends BaseController {

	/**
	 * @页面定向方法
	 */
	@RequestMapping(value = "/redirect/{page1}")
	public String redirect(@PathVariable("page1") String page1) {
		return "manage/" + page1;
	}
	
	/**
	 * @页面定向方法
	 */
	@RequestMapping(value = "/redirect/{page1}/{page2}")
	public String redirect(@PathVariable("page1") String page1, @PathVariable("page2") String page2, 
			HttpServletRequest request) {
		if("allEquip".equals(page1) && !"allEquipList".equals(page2)) {
			String serialNum = request.getParameter("serialNum");
			request.setAttribute("serialNum", serialNum);
		}
		return "manage/" + page1 + "/" + page2;
	}
	
	/**
	 * @获取所有设备列表
	 */
	@RequestMapping(value = "/firstdevTotal")
	public @ResponseBody Object firstdevTotal(String livedata, String require, int pageSize, int curPageNO) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "firstdevTotal");
		//String postUrl = "http://127.0.0.1:8080/airCondition-web/system/loginCheck";//请求接口
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();
		postData.add(new BasicNameValuePair("livedata", livedata));
		postData.add(new BasicNameValuePair("require", require));
		postData.add(new BasicNameValuePair("pageSize", String.valueOf(pageSize)));
		postData.add(new BasicNameValuePair("curPageNO", String.valueOf(curPageNO)));
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @获取所有设备列表
	 */
	@RequestMapping(value = "/seconddevTotal")
	public @ResponseBody Object seconddevTotal(String livedata, String require) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "seconddevTotal");
		//String postUrl = "http://127.0.0.1:8080/airCondition-web/system/loginCheck";//请求接口
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();
		postData.add(new BasicNameValuePair("livedata", livedata));
		postData.add(new BasicNameValuePair("require", require));
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @全部设备-故障分析
	 */
	@RequestMapping(value = "/chtctrupdate")
	public @ResponseBody Object chtctrupdate(String serialNum, String lowerTime, String upperTime) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "chtctrupdate");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		postData.add(new BasicNameValuePair("lowerTime", lowerTime));
		postData.add(new BasicNameValuePair("upperTime", upperTime));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @全部设备-故障分析-当前故障主表
	 */
	@RequestMapping(value = "/errorContentLast")
	public @ResponseBody Object errorContentLast(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorContentLast");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			if("null".equals(body) || "".equals(body)) {
				map.put("status", "FAIL");
			} else {
				JSONObject json = JSONObject.fromObject(body);
				map.put("data", json);
				map.put("status", "OK");
			}
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @故障分析-故障数
	 */
	@RequestMapping(value = "/errorCountByMonthWithSerialNum")
	public @ResponseBody Object errorCountByMonthWithSerialNum(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorCountByMonthWithSerialNum");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @故障分析-故障分类
	 */
	@RequestMapping(value = "/errorCountByType")
	public @ResponseBody Object errorCountByType(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorCountByType");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @故障分析-故障分类-二级
	 */
	@RequestMapping(value = "/errorCountByLevel")
	public @ResponseBody Object errorCountByLevel(String serialNum, String faultType) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorCountByLevel");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		postData.add(new BasicNameValuePair("faultType", faultType));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @故障分析-故障派单
	 */
	@RequestMapping(value = "/maintainPostByFaultId")
	public @ResponseBody Object maintainPostByFaultId(String faultId) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "maintainPostByFaultId");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("faultId", faultId));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			if("null".equals(body) || "".equals(body)) {
				map.put("status", "FAIL");
			} else {
				JSONObject json = JSONObject.fromObject(body);
				map.put("data", json);
				map.put("status", "OK");
			}
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @故障分析-历史故障列表
	 */
	@RequestMapping(value = "/errorListWithSerialNum")
	public @ResponseBody Object errorListWithSerialNum(String serialNum, int pageSize, int curPageNO) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorListWithSerialNum");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		postData.add(new BasicNameValuePair("pageSize", String.valueOf(pageSize)));
		postData.add(new BasicNameValuePair("curPageNO", String.valueOf(curPageNO)));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @故障分析-获取指定波形
	 */
	@RequestMapping(value = "/errorDataById")
	public @ResponseBody Object errorDataById(String id, String dsp) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorDataById");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("id", id));
		postData.add(new BasicNameValuePair("dsp", dsp));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	
	
	/**
	 * @全部设备-历史数据
	 */
	@RequestMapping(value = "/secondhistData")
	public @ResponseBody Object secondhistData(String serialNum, String startTime, String endTime) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistData");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		postData.add(new BasicNameValuePair("startTime", startTime));
		postData.add(new BasicNameValuePair("endTime", endTime));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-历史数据-社会贡献值
	 */
	@RequestMapping(value = "/secondhistDataContribution")
	public @ResponseBody Object secondhistDataContribution(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataContribution");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-历史数据-运行总时长
	 */
	@RequestMapping(value = "/secondhistDataRuntime")
	public @ResponseBody Object secondhistDataRuntime(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataRuntime");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			//JSONArray json = JSONArray.fromObject(body);
			map.put("data", body);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-历史数据-位置
	 */
	@RequestMapping(value = "/secondhistDataLocation")
	public @ResponseBody Object secondhistDataLocation(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataLocation");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-历史数据-故障总数
	 */
	@RequestMapping(value = "/secondhistDataErrorCount")
	public @ResponseBody Object secondhistDataErrorCount(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataErrorCount");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			//JSONObject json = JSONObject.fromObject(body);
			map.put("data", body);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @全部设备-实时数据
	 */
	@RequestMapping(value = "/secondliveData")
	public @ResponseBody Object secondliveData(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondliveData");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-实时数据-天气
	 */
	@RequestMapping(value = "/secondweatherData")
	public @ResponseBody Object secondweatherData(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondweatherData");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @全部设备-能效分析-当日电量
	 */
	@RequestMapping(value = "/secondhistDataPowerToday")
	public @ResponseBody Object secondhistDataPowerToday(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataPowerToday");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-能效分析-耗电概况
	 */
	@RequestMapping(value = "/secondhistDataPowerMax")
	public @ResponseBody Object secondhistDataPowerMax(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataPowerMax");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-能效分析-当月各日的能耗
	 */
	@RequestMapping(value = "/secondhistDataDayCost")
	public @ResponseBody Object secondhistDataDayCost(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataDayCost");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-能效分析-当年各月的能耗
	 */
	@RequestMapping(value = "/secondhistDataMonthCost")
	public @ResponseBody Object secondhistDataMonthCost(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataMonthCost");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @全部设备-能效分析-设备电费统计
	 */
	@RequestMapping(value = "/secondhistDataCost")
	public @ResponseBody Object secondhistDataCost(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "secondhistDataCost");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	
	/**
	 * @分布统计-设备型号
	 */
	@RequestMapping(value = "/chtcapupdate")
	public @ResponseBody Object chtcapupdate(String actval) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "chtcapupdate");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("actval", actval));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-设备型号-右侧1
	 */
	@RequestMapping(value = "/devCountByMonth")
	public @ResponseBody Object devCountByMonth(String actval) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "devCountByMonth");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-设备型号-右侧2
	 */
	@RequestMapping(value = "/devCountByMonthWithProvince")
	public @ResponseBody Object devCountByMonthWithProvince(String province) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "devCountByMonthWithProvince");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("province", province));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-设备型号-右侧3
	 */
	@RequestMapping(value = "/devCountByAreaWithProvince")
	public @ResponseBody Object devCountByAreaWithProvince(String province) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "devCountByAreaWithProvince");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("province", province));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	
	/**
	 * @分布统计-故障代码
	 */
	@RequestMapping(value = "/chtfltupdate")
	public @ResponseBody Object chtfltupdate(String actval1, String actval2) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "chtfltupdate");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("actval1", actval1));
		postData.add(new BasicNameValuePair("actval2", actval2));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-故障代码-右侧1
	 */
	@RequestMapping(value = "/errorCountByMonth")
	public @ResponseBody Object errorCountByMonth(String actval) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorCountByMonth");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-故障型号-右侧2
	 */
	@RequestMapping(value = "/errorCountByMonthWithProvince")
	public @ResponseBody Object errorCountByMonthWithProvince(String province) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorCountByMonthWithProvince");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("province", province));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-故障型号-右侧3
	 */
	@RequestMapping(value = "/errorCountByAreaWithProvince")
	public @ResponseBody Object errorCountByAreaWithProvince(String province) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "errorCountByAreaWithProvince");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("province", province));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	
	/**
	 * @分布统计-零件型号
	 */
	@RequestMapping(value = "/chteleupdate")
	public @ResponseBody Object chteleupdate(String actval) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "chteleupdate");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("actval", actval));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-零件代码-右侧1
	 */
	@RequestMapping(value = "/elementCountByMonth")
	public @ResponseBody Object elementCountByMonth(String actval) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "elementCountByMonth");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-零件型号-右侧2
	 */
	@RequestMapping(value = "/elementCountByMonthWithProvince")
	public @ResponseBody Object elementCountByMonthWithProvince(String province) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "elementCountByMonthWithProvince");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("province", province));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	/**
	 * @分布统计-零件型号-右侧3
	 */
	@RequestMapping(value = "/elementCountByAreaWithProvince")
	public @ResponseBody Object elementCountByAreaWithProvince(String province) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "elementCountByAreaWithProvince");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("province", province));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONArray json = JSONArray.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	
	/**
	 * @分布统计-投运时间
	 */
	@RequestMapping(value = "/chtdatupdate")
	public @ResponseBody Object chtdatupdate(String actval1, String actval2) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "chtdatupdate");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("actval1", actval1));
		postData.add(new BasicNameValuePair("actval2", actval2));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @下拉框数据
	 */
	@RequestMapping(value = "/initopt")
	public @ResponseBody Object initopt(String opttype) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "initopt");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("opttype", opttype));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @下拉框数据(带参数)
	 */
	@RequestMapping(value = "/sltoptupdate")
	public @ResponseBody Object sltoptupdate(String opttype, String actval) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "sltoptupdate");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("opttype", opttype));
		postData.add(new BasicNameValuePair("actval", actval));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @故障信息-故障设备
	 */
	@RequestMapping(value = "/firstdevError")
	public @ResponseBody Object firstdevError(String lowerlimit, String upperlimit, int pageSize, int curPageNO) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "firstdevError");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("lowerlimit", lowerlimit));
		postData.add(new BasicNameValuePair("upperlimit", upperlimit));
		postData.add(new BasicNameValuePair("pageSize", String.valueOf(pageSize)));
		postData.add(new BasicNameValuePair("curPageNO", String.valueOf(curPageNO)));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @故障信息-维保新增_列表
	 */
	@RequestMapping(value = "/managerMatainMana")
	public @ResponseBody Object managerMatainMana(String require, int pageSize, int curPageNO) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "managerMatainMana");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();
		postData.add(new BasicNameValuePair("require", require));
		postData.add(new BasicNameValuePair("pageSize", String.valueOf(pageSize)));
		postData.add(new BasicNameValuePair("curPageNO", String.valueOf(curPageNO)));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @故障信息-维保新增_录入
	 */
	@RequestMapping(value = "/firstmatainAdd")
	public @ResponseBody Object firstmatainAdd(Matain matain) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();
		
		String postUrl = PropertiesUtils.get("config/JSONInterface", "firstmatainAdd");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();
		
		// 获取实体类的所有属性，返回Field数组  
		Field[] field = matain.getClass().getDeclaredFields();  
		// 遍历所有属性  
		for (int j = 0; j < field.length; j++) {  
		    // 获取属性的名字  
		    String name = field[j].getName();  
		    // 将属性的首字符大写，方便构造get，set方法  
		    String Name = name.substring(0, 1).toUpperCase() + name.substring(1);  
		    String value = "";
		    try {
			    Method m = matain.getClass().getMethod("get" + Name);  
	            // 调用getter方法获取属性值  
	            value = (String) m.invoke(matain);  
		    } catch(Exception e) {
		    	continue;
		    }
		    postData.add(new BasicNameValuePair(name, value));
		}
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			//JSONObject json = JSONObject.fromObject(body);
			map.put("data", body);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	/**
	 * @设备详情
	 */
	@RequestMapping(value = "/managerdevdetail")
	public @ResponseBody Object managerdevdetail(String serialNum) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "managerdevdetail");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("serialNum", serialNum));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
	
	
	/**
	 * @格力设备列表
	 */
	@RequestMapping(value = "/managernewdevlist")
	public @ResponseBody Object managernewdevlist(String require, int pageSize, int curPageNO) throws IOException {
		Map<String, Object> map = new HashMap<String, Object>();

		String postUrl = PropertiesUtils.get("config/JSONInterface", "managernewdevlist");
		//String postData = "userName=admin&password=123";//传递数据
		List<NameValuePair> postData = new ArrayList<NameValuePair>();  
		postData.add(new BasicNameValuePair("require", require));
		postData.add(new BasicNameValuePair("pageSize", String.valueOf(pageSize)));
		postData.add(new BasicNameValuePair("curPageNO", String.valueOf(curPageNO)));
		
		try {
			String body = HttpUtils.post(postUrl, postData);//调用请求方法，并返回请求后的数据
			JSONObject json = JSONObject.fromObject(body);
			map.put("data", json);
			map.put("status", "OK");
		} catch(Exception e) {
			map.put("status", "FAIL");
		}
		return map;
	}
}
